<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Controller;
use User\Api\UserApi;

/**
 * 后台用户控制器
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */
class CompController extends AdminController {

   
    public function index(){
        $comp = M('company');

        // var_dump($comp);
        $nickname       =   I('daibiao');
        
        if(is_numeric($nickname)){
            $map['uid|daibiao']=   array(intval($nickname),array('like','%'.$nickname.'%'),'_multi'=>true);
        }else{
            $map['daibiao']    =   array('like', '%'.(string)$nickname.'%');
        }
        
        $count = $comp->where($map)->count();// 查询满足要求的总记录数
        
        $Page = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(10)
        $Page->setConfig('prev','上一页');
        $Page->setConfig('next','下一页');
        $Page->setConfig('last','末页');
        $Page->setConfig('first','首页');
        $Page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
        $show = $Page->show();// 分页显示输出
        
        // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $list = $comp ->order('id')->where($map)->limit($Page->firstRow.','.$Page->listRows)->select();
        // 
        // $list   = $this->lists('company', $map);
        // var_dump($list);
        int_to_string($list);
        $this->assign('_list', $list);
        $this->assign('page', $show);

        // $this->meta_title = '用户信息';
        $this->display('comp/index');
    }
    /*联系方式*/
    public function cont(){
        $cont = M('contact');
        $cid = $_GET['cid'];
        $list = $cont ->where(array('cid'=>$cid)) ->select();
        // var_dump($list);

        $this->assign('_list', $list);
        $this ->display('comp/cont');

    }


    /*公司logo*/
    public function pic(){
        $pic = M('pic');
        $cid = $_GET['cid'];

        $list = $pic ->where(array('cid' =>$cid)) ->select();
        $this ->assign('_list',$list);
        $this ->display('comp/pic');
    }

    /*公司描述*/
    public function des(){
        // $dis = M('description');
        $cid = $_GET['cid'];

        // $map = M('map');
        $result = M()->table(array('onethink_description'=>'d','onethink_map'=>'m'))->where('d.cid='.$cid)->where('d.cid=m.cid')->select(false);
        // $list = $dis ->where(array('cid' =>$cid)) ->select();
        echo $result;
        $this ->assign('_list',$list);
        $this ->display('comp/des');
    }



    /*产品分类*/
    public function pro(){
        $pro = M('product');
        // var_dump($_GET);
        $cid = $_GET['cid'];

        $list = $pro ->where(array('cid' =>$cid)) ->select();
        // var_dump($list);
        $this ->assign('_list',$list);
        $this ->display('comp/pro');
    }
    

    /*团队图片*/
    public function team(){
        $team = M('team');
        $cid = $_GET['cid'];
        // var_dump($team);
        $list = $team ->where(array('cid' =>$cid)) ->select();
        // var_dump($list);

        $this ->assign('_list',$list);
        $this ->display('comp/team');
    }

    /*广告管理*/
    public function gname(){
        $gname = M('gname');
        $cid = $_GET['cid'];
        // var_dump($gname);
        $list = $gname ->where(array('cid' =>$cid)) ->select();
        // var_dump($list);

        $this ->assign('_list',$list);
        $this ->display('comp/gname');

    }

    /*公司案例*/
    public function anli(){
        $anli = M('anli');
        $cid = $_GET['cid'];
        // var_dump($cid);
        $list = $anli ->where(array('cid' =>$cid)) ->select();
        // var_dump($list);

        $this ->assign('_list',$list);
        $this ->display('comp/anli');
    }

    /*友情链接*/
    public function links(){
        $links = M('links');
        $cid = $_GET['cid'];
        // var_dump($cid);
        $list = $links ->where(array('cid' =>$cid)) ->select();
        // var_dump($list);

        $this ->assign('_list',$list);
        $this ->display('comp/links');

    }

  
}



